home *** CD-ROM | disk | FTP | other *** search
- #
- # nice.test
- #
- # Tests for the nice command.
- #---------------------------------------------------------------------------
- # Copyright 1993 Karl Lehenbauer and Mark Diekhans.
- #
- # Permission to use, copy, modify, and distribute this software and its
- # documentation for any purpose and without fee is hereby granted, provided
- # that the above copyright notice appear in all copies. Karl Lehenbauer and
- # Mark Diekhans make no representations about the suitability of this
- # software for any purpose. It is provided "as is" without express or
- # implied warranty.
- #------------------------------------------------------------------------------
- # $Id:
- #------------------------------------------------------------------------------
- #
-
- if {[info procs test] != "test"} then {source testlib.tcl}
-
- #
- # Fork without exec will not work under Tk, skip this test
- #
- if ![lempty [info commands button]] {
- puts stderr "*************************************************************"
- puts stderr "Nice tests are constructed in a way that does not work"
- puts stderr "under Tk. Test skipped."
- puts stderr "*************************************************************"
- puts stderr ""
- return
- }
-
- #
- # Right now, we depend on the base priority being zero.
- #
- if {[nice] != 0} {
- puts stderr "*************************************************************"
- puts stderr "Nice priority is [nice], not zero. Most \"nice\" command"
- puts stderr "test will fail (but everything is probably ok)"
- puts stderr "*************************************************************"
- puts stderr ""
- }
-
- Test nice-1.1 {nice tests} {
- nice 0 1
- } 1 {wrong # args: nice ?priorityincr?}
-
- Test nice-1.2 {nice tests} {
- nice
- } 0 {0}
-
- Test nice-1.2 {nice tests} {
- nice 0
- } 0 {0}
-
- #
- # Since you can't nice back up unless you're root, we spawn a child process
- # to run the nice tests.
- #
-
- set pid [fork]
-
- #
- # Parent waits for child to complete.
- #
- if {$pid > 0} {
- wait $pid
- return
- }
-
- Test nice-1.4 {nice tests} {
- nice 8
- } 0 8
-
- Test nice-1.5 {nice tests} {
- nice 8
- } 0 16
-
- Test nice-1.6 {nice tests} {
- nice 20
- } 0 19
-
- if {[id user] != "root"} {
-
- Test nice-1.7 {nice tests} {
- set stat [catch {nice -1} msg]
- set msg [string tolower $msg]
- if {[lsearch {{not owner} {permission denied}} $msg] < 0} {
- set stat [list $stat $msg]
- }
- set stat
- } 0 1
-
- puts stderr "*************************************************************"
- puts stderr "You are not running as `root', certain nice tests will be"
- puts stderr "skipped"
- puts stderr "*************************************************************"
- exit
- }
-
- Test nice-1.8 {nice tests} {
- nice -1
- } 0 18
-
- Test nice-1.10 {nice tests} {
- nice -9
- } 0 9
-
- Test nice-1.11 {nice tests} {
- nice -10
- } 0 -1
-
- Test nice-1.12 {nice tests} {
- nice -10
- } 0 -11
-
- Test nice-1.13 {nice tests} {
- nice -10
- } 0 -20
-
- exit
-